package com.itheima.convertedio;

import java.io.*;

public class ConvertedDemo5 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
//        method1();
        method2();
    }

    private static void method1() throws IOException, ClassNotFoundException {
        User user = new User("zhangsan", "qwer");

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("a.txt"));
        oos.writeObject(user);

        oos.close();
    }

    private static void method2() throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("a.txt"));

        User o = (User) ois.readObject();
        System.out.println(o);

        ois.close();
    }
}
